import logging

from flask import Flask

from .globalvar import db_scoped_session_init, db_scoped_session_remove
from .blueprints.api import api

app = Flask(__name__)
app.register_blueprint(api, url_prefix='/fun/rest/api')


@app.before_request
def app_db_scoped_session_init():
    db_scoped_session_init()


@app.teardown_request
def app_db_scoped_session_remove(response):
    db_scoped_session_remove()
